(require-package 'evil)
(evil-mode t)
(require-package 'evil-leader)
(global-evil-leader-mode t)
;; 将evil中"C-e"绑定到符合emacs以及其它习惯的功能上
;; "C-a"跳到行首，"C-e"跳到行尾
(define-key evil-motion-state-map (kbd "C-e") 'end-of-visual-line)
;; 绑定"C-d"为行向下滚动快捷键
(define-key evil-motion-state-map (kbd "C-d") 'evil-scroll-line-down)

;; 定义在不同主mode中,隐藏和显示的实现
(defun lugg/pressSPC ()
  (interactive)
  (cond
   ;; c-mode的处理
   ((string-equal "C/l" mode-name)
	(hs-toggle-hiding))
   ;; org-mode的处理
   ((string-equal "Org" mode-name)
	(org-cycle))
   ;; js2-mode的处理
   ((string-equal "Javascript-IDE" mode-name)
	(js2-mode-toggle-element))
   ;; 默认处理
   ((string-equal "equ" "equ")
	(hs-toggle-hiding))))
(evil-leader/set-leader ";")
(evil-leader/set-key
;; 将隐藏/显示绑定到;;键上
   ";" 'lugg/pressSPC
;; 将ace-jump-mode绑定在;a上
   "a" 'ace-jump-mode
;; 打开remember绑定在;j上
   "C-j" 'remember-other-frame
;; 文件查找绑定在;f上
   "f" 'find-file
;; 添加b为查看buffer快捷键
   "b" 'switch-to-buffer
;; 关闭一个buffer
   "k" 'ido-kill-buffer
;; 添加r为查找替换快捷键
   "r" 'query-replace-regexp
;; 添加c为打开日历快捷键
   "c" 'calendar
;; 添加g为magit-status快捷键
   "g" 'magit-status
;; 添加s为打开所有折叠快捷键
   "s" 'hs-show-all
;; 添加c为隐藏所有折叠快捷键
   "h" 'hs-hide-all
;; 添加m为打开菜单栏快捷键
   "m" 'menu-bar-open
;; 添加.为切换最近使用的buffer叠快捷键
   "." 'evil-buffer
;; 添加q为退出快捷键
   "q" 'evil-quit
;; 添加o为打开工具栏快捷键
   "o" 'tool-bar-mode
;; 添加u为打开git图形界面的快捷键
   "u" 'run-git-gui
;; 添加p为org-publish快捷键
   "p" 'org-publish
;; 添加w为保存文件快捷键
   "w" 'save-buffer
;; 添加t为翻译的快捷键
   "t" 'lugg/yasdcv-translate
;; 添加y为有道翻译的快捷键
   ;"y" 'youdao-translate-word
   "y" 'youdao-dictionary-search-at-point+
   "C-p" 'youdao-dictionary-play-voice-at-point
   "C-y" 'youdao-dictionary-search-from-input)

;; 在某些模式中关闭evil
(evil-set-initial-state 'youdao-dictionary-mode 'emacs)

(provide 'init-evil)
